package cn.kgc.ywz.smbms.web.service.impl;

import cn.kgc.ywz.smbms.web.entity.Bill;
import cn.kgc.ywz.smbms.web.entity.Provider;
import cn.kgc.ywz.smbms.web.mapper.BillMapper;
import cn.kgc.ywz.smbms.web.service.BillService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BillServiceImpl implements BillService {

    @Resource
    private BillMapper billMapper;

    @Override
    public PageInfo<Bill> find(Bill condition, Integer pageNum, Integer pageSize) {
        if (pageNum == null) pageNum = 1;
        PageHelper.startPage(pageNum, pageSize);
        List<Bill> billList = this.billMapper.select(condition);
        PageInfo<Bill> pageInfo = new PageInfo<>(billList);
        return pageInfo;
    }

    /**
     * 添加供应商
     */
    @Override
    public int add(Bill bill) {
        return this.billMapper.insert(bill);
    }

    /**
     * 修改订单
     */
    @Override
    public int modif(Bill bill) {
        return this.billMapper.update(bill);
    }

    /**
     * 删除订单
     */
    @Override
    public int remove(Long id) {
        return this.billMapper.delete(id);
    }

    /**
     * 查询订单编码
     */
    @Override
    public Integer findByBillCode(String billCode) {
        return this.billMapper.selectByBillCode(billCode);
    }
}
